package com.dhcc.bpm.modules.log.controller;

import io.swagger.annotations.Api;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;

import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.log.entity.Tps;
import com.dhcc.bpm.modules.log.vo.TpsModelVO;
import com.dhcc.bpm.modules.log.service.ITpsService;
import org.springblade.core.boot.ctrl.BladeController;

/**
 * tps管理表 控制器
 *
 * @author xiafayu
 * @since 2021-05-31
 */
@RestController
@AllArgsConstructor
@RequestMapping("cbus-bpm-boot/tps")
@Api(value = "tps管理表", tags = "tps管理表接口")
public class TpsController extends BladeController {

	private ITpsService tpsService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入tps")
	public R<Tps> detail(Tps tps) {
		Tps detail = tpsService.getOne(Condition.getQueryWrapper(tps));
		return R.data(detail);
	}

	/**
	 * 分页 tps管理表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入tps")
	public R<IPage<Tps>> list(Tps tps, Query query) {
		IPage<Tps> pages = tpsService.page(Condition.getPage(query), Condition.getQueryWrapper(tps));
		return R.data(pages);
	}

	/**
	 * 自定义分页 tps管理表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入tps")
	public R<IPage<TpsModelVO>> page(TpsModelVO tps, Query query) {
		IPage<TpsModelVO> pages = tpsService.selectTpsPage(Condition.getPage(query), tps);
		return R.data(pages);
	}

	/**
	 * 新增 tps管理表
	 */
	@PostMapping("/save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "新增", notes = "传入tps")
	public R save(@Valid @RequestBody Tps tps) {
		return R.status(tpsService.save(tps));
	}

	/**
	 * 修改 tps管理表
	 */
	@PostMapping("/update")
	@ApiOperationSupport(order = 5)
	@ApiOperation(value = "修改", notes = "传入tps")
	public R update(@Valid @RequestBody Tps tps) {
		return R.status(tpsService.updateById(tps));
	}

	/**
	 * 新增或修改 tps管理表
	 */
	@PostMapping("/submit")
	@ApiOperationSupport(order = 6)
	@ApiOperation(value = "新增或修改", notes = "传入tps")
	public R submit(@Valid @RequestBody Tps tps) {
		return R.status(tpsService.saveOrUpdate(tps));
	}

	
	/**
	 * 删除 tps管理表
	 */
	@PostMapping("/remove")
	@ApiOperationSupport(order = 8)
	@ApiOperation(value = "删除", notes = "传入ids")
	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
		return R.status(tpsService.removeByIds(Func.toLongList(ids)));
	}

	
}
